package com.yeraphael.exception;

import com.yeraphael.entity.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(BussinessException.class)
    public Result handleBussinessException(BussinessException e) {
        log.error("业务异常："+e.getMessage());
        return Result.error(e.getMessage());
    }

//    @ExceptionHandler(NullPointerException.class)
    @ExceptionHandler(Exception.class)
    public Result doException(Exception e) {
        log.error("异常："+e.getMessage());
        return Result.error("出错了，请联系管理人员！！");
    }

}
